package offer.offer01;

/**
 * 没写出来
 */
public class S04二维数组中的查找 {
    public boolean findNumberIn2DArray(int[][] matrix, int target) {
        int[][] location = position(matrix, target);
        return false;
    }
    public int[][] position(int[][] matrix, int target) {
        //通过比较target的值与对角线元素的值来快速缩小m n不相等的矩阵的查找范围; 返回左右值的位置;
        int rowNum = matrix.length;
        int colNum = matrix[0].length;
        //按照对角线寻找在target左右两边的对角线数值, 但是这个matrix不一定是方阵;
        int minNum = rowNum > colNum ? colNum : rowNum;
        if(matrix[minNum][minNum] < target) {

        }

        return null;
    }

    public boolean judge(int[][] matrix, int target) {
        return false;
    }

    public static void main(String[] args) {
        int[][] matrix = {
                {1,   4,  7, 11, 15},
                {2,   5,  8, 12, 19},
                {3,   6,  9, 16, 22},
                {10, 13, 14, 17, 24},
                {18, 21, 23, 26, 30}
        };
        int target = 20;
        S04二维数组中的查找 s = new S04二维数组中的查找();
        System.out.println(s.findNumberIn2DArray(matrix, target));
    }
}
